package com.redis.paihangbang;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.beans.factory.annotation.Autowired;
import com.redis.paihangbang.service.RankingService;

@SpringBootApplication
public class PaihangbangApplication {

    public static void main(String[] args) {
        SpringApplication.run(PaihangbangApplication.class, args);
    }

    @Autowired
    private RankingService rankingService;

    // 启动预热：应用就绪后重建全量排行榜缓存
    @EventListener(ApplicationReadyEvent.class)
    public void warmupRankingCache() {
        rankingService.rebuildRankingCache();
    }
}
